<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="perm" uri="/WEB-INF/tld/perm.tld"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<script>
	var ctx = "${ctx}";
</script>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>头条列表</title>
<meta name="keywords" content="">
<meta name="description" content="">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
<meta http-equiv="expires" content="Wed, 26 Feb 209908:21:57 GMT">

<link href="${ctx}/static/css/bootstrap.min.css?v=${static_version}"
	rel="stylesheet" />
<link
	href="${ctx}/static/css/font-awesome.min.css?v=4.4.0?v=${static_version}"
	rel="stylesheet" />
<link href="${ctx}/static/css/animate.min.css?v=${static_version}"
	rel="stylesheet" />
<link href="${ctx}/static/css/style.min.css?v=${static_version}"
	rel="stylesheet" />
<link href="${ctx}/static/css/common.css?v=${static_version}"
	rel="stylesheet" />
<link href="//at.alicdn.com/t/font_9x03jhokyws9vn29.css"
	rel="stylesheet">
<link href="${ctx}/static/css/plugins/webuploader/webuploader.css"
	rel="stylesheet" />
<!-- Data Tables -->
<link
	href="${ctx}/static/css/plugins/dataTables/dataTables.bootstrap.css?v=${static_version}"
	rel="stylesheet" />

</head>
<body class="gray-bg">
	<%-- 	<c:if test="${empty cate_id}">
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>
		文章 <span class="c-gray en">&gt;</span> 文章管理 <a
		class="btn btn-success btn-refresh radius r mt-5 mr-20"
		onclick="javascript:location.replace(location.href);"
		href="javascript:location.replace(location.href);" title="刷新">刷新</a>

		<a class="btn btn-primary radius r mt-5 mr-20"
		onclick="Hui_admin_tab(this)"
		_href="${ctx}/article/articleaddpre" data-title="添加文章"
		href="javascript:void(0);">添加文章</a> <a
		class="btn btn-primary radius r mt-5 mr-20"
		onclick="Hui_admin_tab(this)"
		_href="${ctx}/article/articleaddpre2" data-title="添加图说"
		href="javascript:void(0);">添加图说</a> <a
		class="btn btn-primary radius r mt-5 mr-20"
		onclick="Hui_admin_tab(this)"
		_href="${ctx}/article/articleaddpre3" data-title="添加视频"
		href="javascript:void(0);">添加视频</a>
	</nav>
</c:if> --%>
	<div class="wrapper wrapper-content  animated fadeInRight">
		<div class="ibox float-e-margins">

			<div class="ibox-title clearfix">
				<h5>
					头条列表<small></small>
				</h5>
				<div style="float: right">
					<button name="" id="refresh" class="btn btn-primary radius"
						onclick="javascript:location.replace(location.href);"
						type="submit">刷新</button>
				</div>
			</div>

			<div class="ibox-content">
				<c:if test="${empty cate_id}">

					<form action="${ctx}/article/webarticlelist" method="post"
						class="form form-horizontal clearfix" id="search-form">

						<div class="col-sm-3">
							<div class="col-sm-3 m-t-xs">标题</div>
							<div class="col-sm-9">
								<input type="text" name="title" value="${title}" id="title"
									placeholder="标题" class="form-control">
							</div>
						</div>

						<div class="col-md-9">
							<div class="col-md-1">
								<button name="" id="" class="btn btn-primary radius"
									type="submit">查询</button>
							</div>
							<div class="col-md-1">
								<button name="" onclick="theReset();" id=""
									class="btn btn-primary radius">重置</button>
							</div>
							<div class="col-md-1">
								<a href="javascript:;" onclick="article_delete_batch()"
									class="btn btn-warning btn-outline radius"> 批量删除</a>
							</div>
						</div>
					</form>
				</c:if>

				<div class="mt-20">
					<table
						class="table table-border table-bordered table-hover table-bg table-sort">
						<thead>
							<tr class="text-c">
								<th width="35"><input type="checkbox" name="" value=""></th>
								<th>ID</th>
								<th class="text-center">标题</th>
								<th width="40" class="text-center">点击</th>
								<th width="150" class="text-center">添加时间</th>
								<th class="text-center">分类</th>
								<th width="150" class="text-center">评论列表</th>
								<th width="150" class="text-center">操作</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${u_articles}" var="u_article" varStatus="l">

								<tr class="text-c">
									<td class="text-center"><input type="checkbox"
										value="${u_article.id}" id="id" name="id"></td>
									<td class="text-center">${l.index+1}</td>
									<td>${u_article.title}</td>
									<td class="text-center">${u_article.read_count}</td>
									<td class="text-center">${u_article.add_time}</td>
									<td class="text-center">${u_article.cates_Html}</td>
									<td class="text-center"><a class="btn btn-primary"
										onClick="u_article_discuss(this,'${u_article.id}')"
										href="javascript:void(0);" title="评论列表">评论</a></td>
									<td class="text-center"><a class="btn btn-primary"
										onClick="u_article_edit(this,'${u_article.id}')"
										href="javascript:void(0);" title="编辑">编辑</a> &nbsp;&nbsp;<a
										class="btn btn-primary"
										onClick="u_article_delete(this,'${u_article.id}')"
										href="javascript:void(0);" title="删除">删除</a></td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
	<script src="${ctx}/static/js/jquery.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/bootstrap.min.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/js/plugins/layer/layer.js?v=${static_version}"></script>
	<!-- 插件脚本 -->
	<script
		src="${ctx}/static/js/plugins/dataTables/jquery.dataTables.js?v=${static_version}"></script>
	<script
		src="${ctx}/static/js/plugins/dataTables/dataTables.bootstrap.js?v=${static_version}"></script>
	<script type="text/javascript">
		$(function() {
			$('.table-sort').dataTable({
				"aaSorting" : [ [ 6, "desc" ] ],//默认第几个排序
				"bStateSave" : true,//状态保存
				"aoColumnDefs" : [
				//{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
				{
					"orderable" : false,
					"aTargets" : [ 1, 2 ]
				} // 制定列不参与排序
				]
			});
			$('.table-sort tbody').on('click', 'tr', function() {
				if ($(this).hasClass('selected')) {
					$(this).removeClass('selected');
				} else {
					table.$('tr.selected').removeClass('selected');
					$(this).addClass('selected');
				}
			});
		});

		/*重置*/
		function theReset() {
			$("#search-form input[type='text']").val('');
			$("#search-form select").val(-1);
		}

		/*添加*/
		function u_article_add(title, url, w, h) {
			layer_show(title, url, w, h);
		}

		/*编辑*/
		function u_article_edit(obj, id, w, h) {
			var edit_page = "${ctx}/article/article-show?article_id=" + id;
			var index = layer.open({
				type : 2,
				title : "编辑",
				content : edit_page
			});
			layer.full(index);
		}
		/*评论*/
		function u_article_discuss(obj, id, w, h) {
			var edit_page = "${ctx}/article/u_article_discuss?article_id=" + id;
			var index = layer.open({
				type : 2,
				title : "评论",
				content : edit_page
			});
			layer.full(index);
		}
		/*批量删除*/
		function article_delete_batch() {
			var article_ids = $("input[name='id']:checked");
			var ids = "";
			for (var i = 0; i < article_ids.length; i++) {
				ids += "," + article_ids[i].value;
			}
			//
			layer.confirm('确认删除吗？', {
				btn : [ '确认', '取消' ],
				shade : false
			}, function() {
				$.ajax({
					type : "POST",
					url : "${ctx}/article/article-delete-batch",
					data : "article_ids=" + ids,
					error : function() {
						layer.msg('操作失败', {
							icon : 5,
							time : 1000
						});
					},
					success : function(msg) {
						layer.msg('操作成功 ', {
							icon : 6,
							time : 1000
						});
						$("#refresh").click();
					}
				});
			}, function() {
				layer.msg('未删除', {
					icon : 5,
					time : 1000
				});
			});
		}

		function u_article_show(obj, id) {
			layer.confirm('确认展示？', {
				btn : [ '确认', '取消' ],
				shade : false
			}, function() {
				$.ajax({
					type : "POST",
					url : "${ctx}/article/articleshow",
					data : "article_id=" + id,
					error : function() {
						layer.msg('操作失败', {
							icon : 5,
							time : 1000
						});
					},
					success : function(msg) {
						layer.msg('操作成功', {
							icon : 6,
							time : 1000
						});
						$("#refresh").click();
					}
				});
			}, function() {
				layer.msg('未删除', {
					icon : 5,
					time : 1000
				});
			});
		}

		/*删除*/
		function u_article_delete(obj, id) {
			layer.confirm('确认删除?', {
				btn : [ '确认', '取消' ],
				shade : false
			}, function() {
				$.ajax({
					type : "POST",
					url : "${ctx}/article/articledelete",
					data : "id=" + id,
					error : function() {
						layer.msg('操作失败', {
							icon : 5,
							time : 1000
						});
					},
					success : function(msg) {
						layer.msg('已删除 ' + msg.information, {
							icon : 6,
							time : 1000
						});
						$("#refresh").click();
					}
				});
			}, function() {
				layer.msg('未删除', {
					icon : 5,
					time : 1000
				});
			});
		}
	</script>
</body>
</html>